<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/Widget/zTree/css/zTreeStyle/zTreeStyle.css}" type="text/css">
    <link th:href="@{/erp/Widget/icheck/icheck.css}" rel="stylesheet" type="text/css"/>
    <!--[if IE 7]>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome-ie7.min.css}"/>
    <![endif]-->
    <!--[if lte IE 8]>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace-ie.min.css}"/>
    <![endif]-->
    <script th:src="@{/erp/js/jquery-1.9.1.min.js}"></script>
    <!-- page specific plugin scripts -->
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
    <script type="text/javascript" th:src="@{/erp/Widget/zTree/js/jquery.ztree.all-3.5.min.js}"></script>
    <title>手动分配</title>

</head>

<body>
    <!--手动分配图层-->
    <div class="add_menber" id="add_menber_style">

        <ul class=" page-content">
            <table class="table table-striped table-bordered table-hover" id="sample-table">
                <thead>
                <tr>
                    <th width="10"></th>
                    <th width="60">打印机编号</th>
                    <th width="80">服务器</th>
                    <th width="50">描述</th>
                    <th width="80">可打型号</th>
                    <th width="100">IP地址</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </ul>
        <div class="" style=" text-align:center">
            <input class="btn btn-primary" id="btn_sure" type="button" value="确认打印">
            <input class="btn btn-primary" id="btn_qx" type="reset" value="取消">
        </div>
    </div>
</body>
</html>
<script>
    jQuery(function($) {

        var table = $('#sample-table').dataTable({
            "autoWidth": false,//当重复刷新表格时，我的页面会出现变形的，现象，加了这个就好了
            searching: false,
            serverSide: true,   //开始服务器分页
            destroy:true,
            ajax: {
                url: '/printer/page',
                type: 'get',
            },
            columnDefs: [{"defaultContent": "",
                "targets": "_all"}],
            columns: [
                {
                    "data": "id", "createdCell": function (td, cellData, rowData, row, col) {
                        /*<![CDATA[*/
                        if(row==0){
                            $(td).empty().append('<label><input type="radio" value="' + rowData.id + '" name="dyj" checked="checked"  class="ace"><span\n' +
                                '                                            class="lbl"></span></label>');
                        }else{
                            $(td).empty().append('<label><input type="radio" value="' + rowData.id + '" name="dyj"  class="ace"><span\n' +
                            '                                            class="lbl"></span></label>');
                        }
                    }
                },
                {"data": "lpNum"},
                {"data": "lpServer"},
                {"data": "lpDescribe"},
                {"data": "model"},
                {"data": "ip"},
            ]
        });

       function send () {
           console.log(1);
           window.location.href="/production/laser/sc_jgmPage";
       }

        $("#btn_sure").on("click",function () {
            var pid = $("input[name='dyj']:checked").val();
            $.ajax({
                url:'/laser/sdfp?pid='+pid,
                type:'post',
                contentType : "application/json;charsetset=UTF-8",
                success:function (data) {
                    if (data.rs){
                        layer.msg("操作成功", {
                            icon:1,
                            time: 800,
                            end:function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index);//关闭弹出层
                            }
                        });
                    }else {
                        //关闭弹出窗
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index);//关闭弹出层
                        layer.msg("操作失败", {icon: 2, time: 2000});
                    }
                }
            })
        })

        $("#btn_qx").on("click",function () {
            //关闭弹出窗
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index);//关闭弹出层
        });

    })

</script>
